package com.linkhub.oms.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.yulichang.annotation.EntityMapping;
import com.linkhub.oms.common.enums.mp.OrderProductTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldNameConstants;

import javax.persistence.Transient;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 订单商品信息表
 * </p>
 *
 * @author echo
 * @since 2024-03-28
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "t_order_product", autoResultMap = true)
@ApiModel(value="OrderProductEntity对象", description="订单商品信息表")
@FieldNameConstants
public class OrderProductEntity implements Serializable {


    @ApiModelProperty(value = "主键")
    @TableId(value = "Fid", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "系统orderId")
    @TableField("Fsys_order_id")
    private String sysOrderId;

    @ApiModelProperty(value = "系统商店id")
    @TableField("Fsys_shop_id")
    private String sysShopId;

    @ApiModelProperty(value = "平台商品id")
    @TableField("Fshop_product_id")
    private Long shopProductId;

    @ApiModelProperty(value = "平台商品skuId")
    @TableField("Fshop_sku_id")
    private Long shopSkuId;

    @ApiModelProperty(value = "本地商品skuId")
    @TableField("Fsku_id")
    private String skuId;

    @ApiModelProperty(value = "购买sku")
    @TableField("Fsku_title")
    private String skuTitle;

    @ApiModelProperty(value = "商品单价")
    @TableField("Fprice")
    private String price;

    @ApiModelProperty(value = "商品单价币种")
    @TableField("Fcurrency_code")
    private String currencyCode;

    @ApiModelProperty(value = "当前订单该商品购买数量")
    @TableField("Fcurrent_quantity")
    private Integer currentQuantity;

    @ApiModelProperty(value = "商品类型：1-shopify;2-local")
    @TableField("Fproduct_type")
    private OrderProductTypeEnum productType;

    @ApiModelProperty(value = "创建时间")
    @TableField("Fcreated_time")
    private LocalDateTime createdTime;

    @ApiModelProperty(value = "修改时间")
    @TableField("Fupdate_time")
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "订单商品对应的本地商品信息")
    @TableField(exist = false)
    @Transient
    @EntityMapping(thisField = Fields.skuId, joinField = LocalProductEntity.Fields.skuId)
    private LocalProductEntity localProductEntity;
}
